function reduxPromise({ dispatch }) {
  return function (next) {
    return function (action) {
      if (typeof action === 'object' && typeof action.then === 'function') {
        action.then(dispatch).catch(dispatch)
        return
      }
      return next(action)
    }
  }
}

export default reduxPromise
